public class Main6 {
    public static void main(String[] args) {
        //将这10个对象存入到json文件中并读出到一List集合中
        //写
        Book[] books=new Book[10];
        books[0]=new Book(1,"a","z");
        books[1]=new Book(2,"b","q");
        books[2]=new Book(3,"c","s");
        books[3]=new Book(4,"d","l");
        books[4]=new Book(5,"e","z");
        books[5]=new Book(6,"f","w");
        books[6]=new Book(7,"g","z");
        books[7]=new Book(8,"h","w");
        books[8]=new Book(9,"i","y");
        books[9]=new Book(10,"j","l");
        String string = JSON.toJSONString(books);
        FileWriter fileWriter = new FileWriter("test6.json");
        fileWriter.write(string);
        fileWriter.close();

        //读
        FileReader fr1 = new FileReader("test6.json");
        int len;
        char[] bf = new char[1024];
        while ((len=fr1.read(bf))!=-1){
            List<Book> list = JSON.parseArray(new String(bf, 0, len1), Book.class);
            System.out.println(list);
        }
        fr1.close();
    }
    }
